//
//  HUDUtils.swift
//  vgbox
//
//  Created by Swift Xcode on 2017/5/19.
//  Copyright © 2017 Swift Xcode. All rights reserved.
//

import Foundation
import SVProgressHUD

/// HUD工具类（已替换为SVProgressHUD）
class HUDUtil {
    
    /// 配置HUD全局样式（建议在App启动时调用）
    class func configureHUD() {
        SVProgressHUD.setDefaultStyle(.dark)
        SVProgressHUD.setDefaultMaskType(.black)
        SVProgressHUD.setMinimumDismissTimeInterval(1.5)
    }
    
    /// 显示加载指示器
    class func showHud() {
        SVProgressHUD.show()
    }
    
    /// 隐藏HUD
    class func hideHud() {
        SVProgressHUD.dismiss()
    }
    
    /// 显示带文字的加载指示器
    class func showBlackIndiView(text: String? = Constant_Toast.loadText) {
        SVProgressHUD.show(withStatus: text)
    }
    
    /// 显示纯文本提示
    class func showBlackTextView(text: String?, detailText: String? = nil, delay: Double? = 1.5, callback:(() -> Void)? = nil) {
        guard let text = text else { return }
        SVProgressHUD.showInfo(withStatus: text)
        
        if let delay = delay {
            SVProgressHUD.dismiss(withDelay: delay) {
                callback?()
            }
        }
    }
    
    /// 显示成功提示
    class func showHudWithSucceed(text: String?, callback: (() -> Void)?) {
        SVProgressHUD.showSuccess(withStatus: text)
        SVProgressHUD.dismiss(withDelay: 1.5) {
            callback?()
        }
    }
    
    /// 显示失败提示
    class func showHudWithFailed(text: String?, callback:(() -> Void)?) {
        SVProgressHUD.showError(withStatus: text)
        SVProgressHUD.dismiss(withDelay: 1.5) {
            callback?()
        }
    }
    
    /// 显示自定义视图（SVProgressHUD对自定义视图支持有限，建议使用系统方法）
    class func showCustomView(view: UIView?, text: String?, delay: Double? = nil) {
        // SVProgressHUD的custom实现方式不同，建议使用其他方式
    }
    
    /// 显示带图标的警告视图
    class func showWarCustomView(icon: String?, text: String?, delay: Double? = nil) {
        // 需要自定义实现或使用其他提示方式
    }
    
    /// 显示红色警告提示
    class func showRedTipHud(text: String) {
        SVProgressHUD.setBackgroundColor(.red)
        SVProgressHUD.setForegroundColor(.white)
        SVProgressHUD.showInfo(withStatus: text)
        SVProgressHUD.dismiss(withDelay: 1.5)
        // 重置为默认样式
        configureHUD()
    }
    
    /// 显示进度条
    class func showProgressView(progress: Float, status: String? = nil) {
        SVProgressHUD.showProgress(progress, status: status)
    }
}


struct Constant_Toast {
    
    static let loadText: String = "正在加载"
    
    static let loadingText: String = "正在加载..."
    
    static let loadFailed: String = "加载失败"
    
    static let loginIn: String = "正在登录..."
    
    static let loginOut: String = "正在退出..."
    
    static let smsCodeRequ: String = "验证码已发送，注意查收"
    
    static let accountChanging: String = "正在切换..."
    
    static let accountChangeSuccess: String = "切换成功"
    
    static let publishing: String = "正在发布"
    
    static let publishSuccess: String = "发布成功"
    
    static let searching: String = "正在搜索"
    
    static let comingSoon: String = "敬请期待~"
    
    static let commiting: String = "正在提交"
    
    static let saving: String = "正在保存"
    
    static let saveSuccess: String = "保存成功"
    
    static let saveFailed: String = "保存失败"
    
    static let deleting: String = "正在删除"
    
    static let deleteSuccess: String = "删除成功"
    
    static let deleteFailed: String = "删除失败"
    
    static let screening: String = "正在屏蔽"
    
    static let screenSuccess: String = "屏蔽成功"
    
    static let requestFailed: String = "请求失败"

    static let editing: String = "正在编辑"

    static let editSuccess: String = "编辑成功"
    
    static let editFailed: String = "编辑失败"
    
    static let adding: String = "正在添加"
    
    static let addSuccess: String = "添加成功"
    
    static let addFailed: String = "添加失败"

    static let changeSuccess: String = "修改成功"

    static let changeFailed: String = "修改失败"
    
    static let ry_buy_max: String = "已是最大数量"

    static let uploadError: String = "上传失败"
    
    static let fabiaoSuccess: String = "发布成功，等待审核"
    static let bianjiSuccess: String = "编辑成功，等待审核"

}
